<?php
if(!defined('IN_KKFRAME')) exit();
if(!$_K['member']['adminid']) showmessage('您无权访问管理面板');
if($_GET['action']=='delete_post'){
	$pid = intval($_GET['pid']);
	if($_GET['hash']!=$_K['formhash']) showmessage('HASH 值错误，请重试', referer());
	if(!$pid) showmessage('参数错误', referer());
	$tid = DB::result_first("SELECT tid FROM post WHERE pid='{$pid}'");
	$author = DB::result_first("SELECT author FROM post WHERE pid='{$pid}'");
	if(!$tid) showmessage('参数错误', referer());
	$thread = DB::fetch_first("SELECT * FROM thread WHERE tid='{$tid}'");
	DB::query("UPDATE post SET deleted='1' WHERE pid='{$pid}'");
	send_notice($author, "{$_K[member][username]} 删除了您在帖子《<a href=\"thread.php?id={$tid}\" target=\"_blank\">{$thread[subject]}</a>》中的回复");
	showmessage('成功删除', referer(), 0);
}elseif($_GET['action']=='delete_thread'){
	$tid = intval($_GET['tid']);
	if($_GET['hash']!=$_K['formhash']) showmessage('HASH 值错误，请重试', referer());
	if(!$tid) showmessage('参数错误', referer());
	$thread = DB::fetch_first("SELECT * FROM thread WHERE tid='{$tid}'");
	DB::query("DELETE FROM post WHERE tid='{$tid}'");
	DB::query("DELETE FROM thread WHERE tid='{$tid}'");
	send_notice($thread['author'], "{$_K[member][username]} 删除了您的帖子《{$thread[subject]}》");
	showmessage('成功删除', './', 0);
}elseif($_GET['action']=='move_thread'){
	$tid = intval($_GET['tid']);
	$fid = intval($_GET['fid']);
	if($_GET['hash']!=$_K['formhash']) showmessage('HASH 值错误，请重试', referer());
	if(!$tid) showmessage('参数错误', referer());
	DB::query("UPDATE thread SET fid='{$fid}' WHERE tid='{$tid}'");
	showmessage('分类成功', referer(), 0);
}
showmessage('参数错误', referer());